/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TPointDetail;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TPointDetailDao;
import com.ruipengkj.service.TPointDetailService;
/**
 * 说明：
 * 单据商品明细Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TPointDetailServiceImpl implements TPointDetailService{

	@Resource
	private TPointDetailDao tPointDetailDao;//DAO层
	
	//根据条件查询
	@Override
	public List<TPointDetail> findService(TPointDetail entity) throws Exception {
		String hql = "select o from TPointDetail o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
		
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		List<TPointDetail> list=tPointDetailDao.findDao(hql, whereHQL.toString(), param, orderby);
		return list;
	}
	//根据条件删除
//	@Override
//	public boolean deleteService(TPointDetail entity) throws Exception {
//		String hql = "select o from TPointDetail o";
//		StringBuffer whereHQL = new StringBuffer();
//		List<Object> param = new ArrayList<Object>();
//		if (entity != null) {
//			
//			if(whereHQL.length()>4)
//				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
//		}
//		List<TPointDetail> list=TPointDetail.findDao(hql, whereHQL.toString(), param, null);
//		if(list!=null&&list.size()!=0){
//			for(int i = list.size()-1; i >= 0 ; --i) {
//				TPointDetail com=list.get(i);
//				if(com!=null){
//					tPointDetailDao.deleteDao(com.getPointDetailID());
//				}
//			}
//			return true;
//		}
//		return false;
//	}

	//根据ID翻页查询
	@Override
	public PageModel<TPointDetail> getScrollService(int firstResult,
			int maxResult, TPointDetail entity) throws Exception {
		String hql = "select o from TPointDetail o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tPointDetailDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	
	//修改
	@Override
	public void modifyService(TPointDetail entity) throws Exception {
		tPointDetailDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TPointDetail entity) throws Exception {
		tPointDetailDao.saveDao(entity);
	}

	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		tPointDetailDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TPointDetail getByIdService(String id) throws Exception {
		return tPointDetailDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TPointDetail entity) throws Exception {
		tPointDetailDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TPointDetail entity) throws Exception {
		return tPointDetailDao.saveRetDao(entity);
	}
	public TPointDetailDao gettBillDetailDao() {
		return tPointDetailDao;
	}

	public void settBillDetailDao(TPointDetailDao tPointDetailDao) {
		this.tPointDetailDao = tPointDetailDao;
	}
}
